'''
Created on Jun 23, 2010

@author: Tom Smith
'''
import MySQLdb

def databaseConnectDict():
    conn = MySQLdb.connect (host = "",
                           user = "tom",
                           passwd = "",
                           db = "gadoimages")
    cursor = conn.cursor (MySQLdb.cursors.DictCursor) 
    return cursor

def databaseGetConn():
    conn = MySQLdb.connect (host = "",
                           user = "tom",
                           passwd = "",
                           db = "gadoimages")
    cursor = conn.cursor (MySQLdb.cursors.DictCursor) 
    return conn

def getCursorFromConn(conn):
    return conn.cursor (MySQLdb.cursors.DictCursor)

def executeCommand(command, cursor):
    try:
        cursor = cursor.execute(command)
        return cursor
    except:
        cursor = databaseConnectDict()
        return cursor.execute(command)
    
